// import { getCurrentInstance } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import { constantRoute, anyRoute } from './router-data'
// import useUserStore from '@/store/modules/user'

//创建路由
const router = createRouter({
  //路由hash模式
  history: createWebHashHistory(),
  routes: [...constantRoute, anyRoute],
  //滚动行为
  scrollBehavior: () => {
    return {
      left: 0,
      top: 0,
    }
  },
})
router.beforeEach((to, from, next) => {
  /* if (to.fullPath !== '/login') {
    const userStore = useUserStore()
    if (userStore.token === '') {
      next({ name: 'login' })
      return
    }
  } */

  next()
})
export default router
